<template>
    <div>
        <el-form :model="ruleForm" :rules="rules" ref="ruleForm" label-width="180px" class="demo-ruleForm">
            <el-form-item label="nginx文件夹路径" prop="nginx_path">
                <el-input v-model="ruleForm.nginx_path"></el-input>
            </el-form-item>

            <el-form-item>
                <el-button type="primary" @click="submitForm('ruleForm')">保存</el-button>
            </el-form-item>
        </el-form>

    </div>
</template>

<script>
export default {
    name: "system",
    data() {
        return {
            ruleForm: {
                nginx_path: '',

            },
            rules: {
                nginx_path: [
                    { required: true, message: '请输入nginx文件夹路径', trigger: 'blur' },
                ]

            }
        };
    },
    methods: {
        submitForm(formName) {
            this.$refs[formName].validate((valid) => {
                if (valid) {
                    this.$api.saveConfig(this.ruleForm).then(res=>{
                        this.$message({
                            message: '保存成功',
                            type: 'success'
                        });
                    })
                } else {
                    console.log('error submit!!');
                    return false;
                }
            });
        },
        resetForm(formName) {
            this.$refs[formName].resetFields();
        },
        getConfig(){
            this.$api.getConfigList().then(res=>{
                this.ruleForm = res
            })
        }
    },
    mounted() {
        this.getConfig()
    }
}
</script>

<style scoped lang="scss">

</style>